home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Development / RAVE DDK 1.0.6 GM for MacOS / Projects / Empty Engine Code / TtState.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-30  |  4.7 KB  |  172 lines  |  [TEXT/MPCC]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        TtState.c                                                 **
  4.  **                                                                          **
  5.  **     Purpose:     Empty rasterizer drawing engine.                         **
  6.  **                 Methods for state variable maintenance.                     **
  7.  **                                                                          **
  8.  **     Author:        Mike W. Kelley                                             **
  9.  **                                                                          **
  10.  **                    2/3/95    Revised for 0.9 SDK release                         **
  11.  **                                                                          **
  12.  **     Copyright (C) 1994-95 Apple Computer, Inc.  All rights reserved.     **
  13.  **     Apple Computer Confidential                                             **
  14.  **                                                                          **
  15.  *****************************************************************************/
  16.  
  17. #include "Drive3D.h"
  18. #include "Drive3D_system.h"
  19. #include "TtTinselTown.h"
  20.  
  21. /************************************************************************************************
  22.  *    TtSetFloat.
  23.  ***********************************************************************************************/
  24.  
  25. void TtSetFloat (
  26.     TQADrawContext        *drawContext,        /* Draw context */
  27.     TQATagFloat            tag,                /* Tag of variable to set */
  28.     float                newValue)            /* New value for variable */
  29. {
  30.     TTtDrawPrivate        *myPrivate;
  31.  
  32.     if (tag > kTtMaxTag)
  33.     {
  34.         /*
  35.          * Tag value is out of range; no-op.
  36.          */
  37.         
  38.         return;
  39.     }
  40.     myPrivate = (TTtDrawPrivate *) drawContext->drawPrivate;
  41.     myPrivate->state [tag].f = newValue;
  42.     
  43.     /*
  44.      * Note that this function received a TQADrawContext pointer which is _not_ const.
  45.      * This means you can change the methods based on the set operation.
  46.      */
  47. }
  48.  
  49. /************************************************************************************************
  50.  *    TtSetInt
  51.  ***********************************************************************************************/
  52.  
  53. void TtSetInt (
  54.     TQADrawContext        *drawContext,        /* Draw context */
  55.     TQATagInt            tag,                /* Tag of variable to set */
  56.     unsigned long        newValue)            /* New value for variable */
  57. {
  58.     TTtDrawPrivate        *myPrivate;
  59.  
  60.     myPrivate = (TTtDrawPrivate *) drawContext->drawPrivate;
  61.     if (tag > kTtMaxTag)
  62.     {
  63.         /*
  64.          * Tag value is out of range; no-op.
  65.          */
  66.         
  67.         return;
  68.     }
  69.     myPrivate->state [tag].i = newValue;
  70.     
  71.     /*
  72.      * Note that this function received a TQADrawContext pointer which is _not_ const.
  73.      * This means you can change the methods based on the set operation (e.g., if
  74.      * the texture op is changed)
  75.      */
  76. }
  77.  
  78. /************************************************************************************************
  79.  *    TtSetPtr
  80.  ***********************************************************************************************/
  81.  
  82. void TtSetPtr (
  83.     TQADrawContext        *drawContext,        /* Draw context */
  84.     TQATagPtr            tag,                /* Tag of variable to set */
  85.     const void            *newValue)            /* New value for variable */
  86. {
  87.     TTtDrawPrivate        *myPrivate;
  88.  
  89.     myPrivate = (TTtDrawPrivate *) drawContext->drawPrivate;
  90.     if (tag > kTtMaxTag)
  91.     {
  92.         /*
  93.          * Tag value is out of range; no-op.
  94.          */
  95.         
  96.         return;
  97.     }
  98.     myPrivate->state [tag].p = newValue;
  99.     
  100.     /*
  101.      * Note that this function received a TQADrawContext pointer which is _not_ const.
  102.      * This means you can change the methods based on the set operation (e.g., if
  103.      * the texture op is changed)
  104.      */
  105. }
  106.  
  107. /************************************************************************************************
  108.  *    TtGetFloat
  109.  ***********************************************************************************************/
  110.  
  111. float TtGetFloat (
  112.     const TQADrawContext    *drawContext,        /* Draw context */
  113.     TQATagFloat                tag)                /* Tag of variable to get */
  114. {
  115.     TTtDrawPrivate        *myPrivate;
  116.  
  117.     if (tag > kTtMaxTag)
  118.     {
  119.         /*
  120.          * Tag value is out of range; return 0.
  121.          */
  122.         
  123.         return (0);
  124.     }
  125.     myPrivate = (TTtDrawPrivate *) drawContext->drawPrivate;
  126.     return (myPrivate->state [tag].f);
  127. }
  128.  
  129. /************************************************************************************************
  130.  *    TtGetInt
  131.  ***********************************************************************************************/
  132.  
  133. unsigned long TtGetInt (
  134.     const TQADrawContext    *drawContext,        /* Draw context */
  135.     TQATagInt                tag)                /* Tag of variable to get */
  136. {
  137.     TTtDrawPrivate        *myPrivate;
  138.  
  139.     if (tag > kTtMaxTag)
  140.     {
  141.         /*
  142.          * Tag value is out of range; return 0.
  143.          */
  144.         
  145.         return (0);
  146.     }
  147.     myPrivate = (TTtDrawPrivate *) drawContext->drawPrivate;
  148.     return (myPrivate->state [tag].i);
  149. }
  150.  
  151. /************************************************************************************************
  152.  *    TtGetPtr
  153.  ***********************************************************************************************/
  154.  
  155. void *TtGetPtr (
  156.     const TQADrawContext    *drawContext,        /* Draw context */
  157.     TQATagPtr                tag)                /* Tag of variable to get */
  158. {
  159.     TTtDrawPrivate        *myPrivate;
  160.  
  161.     if (tag > kTtMaxTag)
  162.     {
  163.         /*
  164.          * Tag value is out of range; return 0.
  165.          */
  166.         
  167.         return (0);
  168.     }
  169.     myPrivate = (TTtDrawPrivate *) drawContext->drawPrivate;
  170.     return ((void *) myPrivate->state [tag].p);
  171. }
  172.